<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <meta http-equiv="X-UA-Compatible" content="ie=edge">
  <style>
    .top{
      height:1500px;
    }
    .footer{
      height:1000px;
    }
    .flex_box{
      width:500px;
      height:300px;
      border:1px solid lightcoral;
    }
    .flex_item{
      width:100px;
      height:100px;
      border:1px solid lightblue;
      display:inline-block;
    }
  </style>
  <title>Document</title>
</head>
<body>
  <div class="top">
    <div class="flex_box">
      <div class="flex_item"></div>
      <div class="flex_item"></div>
      <div class="flex_item"></div>
    </div>
  </div>
  <div class="bottom">
    <h1>hello</h1>
    <h1>hello</h1>
    <h1>hello</h1>
    <h1>hello</h1>
    <h1>hello</h1>
    <h1>hello</h1>
    <h1>hello</h1>
  </div>
  <div class="footer">
    <button class="btn">点击</button>
  </div>
  <script src="https://cdn.bootcss.com/jquery/3.4.1/jquery.min.js"></script>
  <script>
    var index = 0
    $(window).scroll(function(){
      var h1 = $('h1')
      var st = $(this).scrollTop()
      var wh = $(this).height()
      $.each(h1, function(i, n){
        if(st >= $(n).offset().top){
          index = i
        }
      })
      
    })
    var a = 0
    $(".btn").on("click", function(){
      $('html,body').animate({scrollTop: $('h1').eq(a++).offset().top+'px'}, 500)
    })
    /**
      position:relative; 尽量不用定位实现位置，多使用inline-block vertical-align
      上下用margin padding 
      左右 inline-block float vertical-align
      inline-block + vertical-align

    */ 
  </script>
</body>
</html>